package com.qiangesoft.blog.controller.manage;

import com.qiangesoft.blog.common.annotation.OperationLog;
import com.qiangesoft.blog.common.mvc.PageQuery;
import com.qiangesoft.blog.common.mvc.PageResultVO;
import com.qiangesoft.blog.system.entity.SysNotice;
import com.qiangesoft.blog.system.service.ISysNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 通知管理 前端控制器
 * </p>
 *
 * @author qiange
 */
@RestController
@RequestMapping("/system/notice")
@Api(tags = "通知管理")
@RequiredArgsConstructor
public class SysNoticeController {

    private final ISysNoticeService noticeService;

    @GetMapping(value = "/list")
    @ApiOperation(value = "字典类型列表")
    public PageResultVO<SysNotice> list(PageQuery pageQuery, String title, Boolean isPublish) {
        return noticeService.listNotice(pageQuery, title, isPublish);
    }

    @PostMapping(value = "/add")
    @ApiOperation(value = "添加字典")
    @OperationLog(value = "添加字典")
    public void insert(@RequestBody SysNotice sysNotice) {
        noticeService.insertNotice(sysNotice);
    }

    @PutMapping(value = "/update")
    @ApiOperation(value = "修改字典")
    @OperationLog(value = "修改字典")
    public void update(@RequestBody SysNotice sysNotice) {
        noticeService.updateNotice(sysNotice);
    }

    @PutMapping(value = "/top")
    @ApiOperation(value = "修改字典")
    @OperationLog(value = "修改字典")
    public void top(@RequestBody SysNotice sysNotice) {
        noticeService.updateNotice(sysNotice);
    }

    @DeleteMapping(value = "/delete")
    @ApiOperation(value = "删除字典")
    @OperationLog(value = "删除字典")
    public void deleteDict(Long id) {
        noticeService.deleteNotice(id);
    }

    @DeleteMapping(value = "/deleteBatch")
    @ApiOperation(value = "批量删除字典")
    @OperationLog(value = "批量删除字典")
    public void deleteBatch(@RequestBody List<Long> list) {
        noticeService.deleteBatch(list);
    }
}

